package allwe.lock;

public class VisibilityTest {

    private static boolean flag = true;

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
           while (flag) {

           }
            System.out.println("t1 执行结束");
        });

        t1.start();

        Thread.sleep(2000);

        flag = false;
        System.out.println("flag:" + flag);
    }
}
